package com.cpi.cornpp.distributioncost.service;

import com.cpi.cornpp.common.exception.CornPPException;
import com.cpi.cornpp.distributioncost.dao.DistributionCostVersionDAO;
import com.cpi.cornpp.distributioncost.exception.DistributionCostVersionException;

public class DistributionCostVersionService {
	public void add(int versionId) throws DistributionCostVersionException{
		DistributionCostVersionDAO distributionCostVersionDAO = null;
		try{			
			distributionCostVersionDAO = new DistributionCostVersionDAO();
			distributionCostVersionDAO.add(versionId);
		} catch (DistributionCostVersionException distributionCostVersionException) {
			throw distributionCostVersionException;
		} catch (Exception e){
			DistributionCostVersionException distributionCostVersionException = null;
			e.printStackTrace(System.out);
			distributionCostVersionException = new DistributionCostVersionException(e , CornPPException.LAYER_SERVICE,CornPPException.ACTION_INSERT);
			throw distributionCostVersionException;
		}
	}
	
	public void delete(int versionId) throws DistributionCostVersionException{
		DistributionCostVersionDAO distributionCostVersionDAO = null;
		try{			
			distributionCostVersionDAO = new DistributionCostVersionDAO();
			distributionCostVersionDAO.delete(versionId);
		} catch (DistributionCostVersionException distributionCostVersionException) {
			throw distributionCostVersionException;
		} catch (Exception e){
			DistributionCostVersionException distributionCostVersionException = null;
			e.printStackTrace(System.out);
			distributionCostVersionException = new DistributionCostVersionException(e , CornPPException.LAYER_SERVICE,CornPPException.ACTION_DELETE);
			throw distributionCostVersionException;
		}
	}
}